<template>
    <div>
 <h2>房号添加</h2>
<table class="table">
<tbody>
    <tr>
        <td>房号名称</td>
        <td>
          <input type="text" v-model="model.Code">
        </td>
    </tr>


    <tr>
        <td>房型</td>
        <td>
            <select v-model="model.Typesss">
                <option :value="-1" >请选择</option>
                <option value="总统套大房" >总统套大房</option>
                <option value="商务房" >商务房</option>
                <option value="单人房" >单人房</option>
                <option value="双人房" >双人房</option>
            </select>
        </td>
    </tr>


    <tr>
        <td>房型状态</td>
        <td>
            <input type="radio" name="fangstate" value="1" v-model="model.FangState">满人
            <input type="radio" name="iswn" value="0"  v-model="model.FangState">空闲
        </td>
    </tr>


    <tr>
        <td>状态</td>
        <td>
            <input type="radio" name="state" value="1"  v-model="model.State">上架
            <input type="radio" name="state" value="0" v-model="model.State">下架
        </td>
    </tr>

    <tr>
        <td></td>
        <td>
            <input type="button" value="添加" class="btn  btn-success" @click="ok">
        </td>
    </tr>
</tbody>
</table>

    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { ref,reactive } from 'vue';
import { useRoute,useRouter } from 'vue-router';
const route=useRoute();
const router=useRouter();


let model=reactive({

"Code": '',
"Typesss": '',
"FangState": 1,
"State": 1,
})

const ok=()=>{
if(model.Code==""){
    alert('房型号不能为空');
    return;
}

if(model.Typesss==""){
    alert('房型不能为空');
    return;
}

axios({
url:'https://localhost:7229/api/House/HouseNoAdd',
method:'post',
data:model,

})
.then((res)=>{

    console.log(res);
     if(res.data==-1){
        alert('房号已经重复')
        return;
     }
    
    else if(res.data==1){
        alert('添加成功')
        router.push('/HouseNoList');
        return;
        
    }

    else{
        alert('添加失败')
        return;
    }


})

.catch((ree)=>{

console.log(ree);
})





}



</script>

<style scoped>

</style>